﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using DAL;
using MOD;

namespace BLL
{
    public class B_LatLonCorrection
    {
        private int iDataConn =  DataBase.IN_S1;
        public int Insert( M_LatLonCorrection mLlc)
        {
            DataBase dDb = new DataBase();
            StringBuilder sCmdText = new StringBuilder();
            //DES.Encryption eEn = new Encryption();
            //eEn.Encrypt();

            sCmdText.Append("Insert into Correction ");
            sCmdText.Append("(lat,lon,latc,lonc,city,[index],[datetime] )");
            sCmdText.Append("values");
            sCmdText.Append("(@lat,@lon,@latc,@lonc,@city,@index,@datetime)");
           
            SqlParameter[] sSp = {
                                   new SqlParameter("@lat",SqlDbType.Float),
                                   new SqlParameter("@lon",SqlDbType.Float),
                                   new SqlParameter("@latc",SqlDbType.Float),
                                   new SqlParameter("@lonc",SqlDbType.Float),
                                   new SqlParameter("@city",SqlDbType.Char,20),
                                   new SqlParameter("@index",SqlDbType.Int),
                                   new SqlParameter("@datetime",SqlDbType.DateTime)           
                                };
            sSp[0].Value = mLlc.Lat;
            sSp[1].Value = mLlc.Lon;
            sSp[2].Value = mLlc.Latc;
            sSp[3].Value = mLlc.Lonc;
            sSp[4].Value = mLlc.City;
            sSp[5].Value = mLlc.Index;
            sSp[6].Value = mLlc.Datetime;

            return dDb.ExecuteCmd(sCmdText.ToString(), iDataConn, sSp);
        }
        public DataTable SelectCorrection()
        {
            DataBase dDb = new DataBase();
            StringBuilder sCmdText = new StringBuilder();
            sCmdText.Append("Select * from Correction order by [datetime]");
            SqlParameter[] sSp = {       
                                };

            return dDb.GetDataTable(sCmdText.ToString(), iDataConn, sSp);
        }
    }
}
